/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package translate;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ayca
 */
public class TranslateContent {

    public TranslateContent()
    {
        
    }
    public String translate(String content){
        String res="";
        Translate.setHttpReferrer("http://en.wikipedia.org/wiki/Cooperation");
        try {
            int length = content.length();
            int num = length/500 +1;
            String translatedText ="";
            for (int i=0;i<num-1;i++)
            {
            translatedText += Translate.execute(content.substring(500*i,500*(i+1)), Language.ENGLISH, Language.TURKISH);
            }
           translatedText += Translate.execute(content.substring(500*(num-1),length), Language.ENGLISH, Language.TURKISH);

            res=translatedText;
        } catch (Exception ex) {
            Logger.getLogger(TranslateContent.class.getName()).log(Level.SEVERE, null, ex);
        }
        return res;
    }
}
